﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using CivilleWP7.CivilleDataServiceReference;
using System.Windows.Media.Imaging;

namespace CivilleWP7.Views.Controls
{
    public partial class LeaderboardTileControl : UserControl
    {
        private CivilleUser civilleUser;
        private int position;

        public int Position
        {
            get { return position; }
            set { position = value; this.UserPositionTextBlock.Text = value.ToString(); }
        }

        public CivilleUser CivilleUser
        {
            get { return this.civilleUser; }
            set
            {
                this.civilleUser = value;
                this.UserNameTextBlock.Text = this.civilleUser.FirstName;
                if (this.civilleUser.Logo != null && this.civilleUser.Logo.Equals(""))
                {
                    this.UserImage.Source = new BitmapImage(new Uri(this.civilleUser.Logo, UriKind.Absolute));
                }
                else
                {
                    this.UserImage.Source = new BitmapImage(new Uri("/CivilleWP7;component/Resources/Images/User-icon.png", UriKind.Relative));
                }
                this.PointsTextBlock.Text = "Level: " + this.civilleUser.CurrentLevel;
            }
        }
        public LeaderboardTileControl()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(LeaderboardTileControl_Loaded);
        }

        void LeaderboardTileControl_Loaded(object sender, RoutedEventArgs e)
        {
 
        }
    }
}
